import * as data_format from "../data/format";
import * as math_tools from "./math_tools";
export { CreateEmptyProperty, CreateProperty, AlterProperty, MergeProperty, GetProperty, SetProperty, };
function RandomRune() {
    const runes = [
        data_format.RUNE_ENUM.blue,
        data_format.RUNE_ENUM.green,
        data_format.RUNE_ENUM.orange,
        data_format.RUNE_ENUM.red,
        data_format.RUNE_ENUM.purple
    ];
    const randomIndex = math_tools.Random({ min: 0, max: runes.length });
    return runes[randomIndex];
}
;
function CreateProperty(entity, input) {
    const setProperty = (key) => {
        entity.setDynamicProperty(`rune_hurt:${key}`, input?.[key] ?? RUNE_PROPERTY_DEFAULT[key]);
    };
    setProperty('raise_basic_attack');
    setProperty('raise_erupt_odds');
    setProperty('raise_erupt_hurt');
    setProperty('damage_increase');
    setProperty('double_damage');
    setProperty('basic_attack');
    setProperty('erupt_hurt');
    setProperty('erupt_odds');
    setProperty('add_rune');
    entity.setDynamicProperty('rune_hurt:self_rune', input?.self_rune ?? RandomRune());
}
;
function SetProperty(object, input) {
    const proto = GetProperty(object);
    object.setDynamicProperty('rune_hurt:basic_attack', input.basic_attack ?? proto.basic_attack);
    object.setDynamicProperty('rune_hurt:raise_basic_attack', input.raise_basic_attack ?? proto.raise_basic_attack);
    object.setDynamicProperty('rune_hurt:erupt_odds', input.erupt_odds ?? proto.erupt_odds);
    object.setDynamicProperty('rune_hurt:raise_erupt_odds', input.raise_erupt_odds ?? proto.raise_erupt_odds);
    object.setDynamicProperty('rune_hurt:erupt_hurt', input.erupt_hurt ?? proto.erupt_hurt);
    object.setDynamicProperty('rune_hurt:raise_erupt_hurt', input.raise_erupt_hurt ?? proto.raise_erupt_hurt);
    object.setDynamicProperty('rune_hurt:damage_increase', input.damage_increase ?? proto.damage_increase);
    object.setDynamicProperty('rune_hurt:double_damage', input.double_damage ?? proto.double_damage);
    object.setDynamicProperty('rune_hurt:add_rune', input.add_rune ?? proto.add_rune);
    object.setDynamicProperty('rune_hurt:self_rune', input.self_rune ?? proto.self_rune);
}
;
function AlterProperty(object, input) {
    if (!object.getDynamicProperty('entity:is_initial'))
        return;
    const proto = GetProperty(object);
    if (input.basic_attack)
        object.setDynamicProperty('rune_hurt:basic_attack', proto.basic_attack + input.basic_attack);
    if (input.raise_basic_attack)
        object.setDynamicProperty('rune_hurt:raise_basic_attack', proto.raise_basic_attack + input.raise_basic_attack);
    if (input.erupt_odds)
        object.setDynamicProperty('rune_hurt:erupt_odds', proto.erupt_odds + input.erupt_odds);
    if (input.raise_erupt_odds)
        object.setDynamicProperty('rune_hurt:raise_erupt_odds', proto.raise_erupt_odds + input.raise_erupt_odds);
    if (input.erupt_hurt)
        object.setDynamicProperty('rune_hurt:erupt_hurt', proto.erupt_hurt + input.erupt_hurt);
    if (input.raise_erupt_hurt)
        object.setDynamicProperty('rune_hurt:raise_erupt_hurt', proto.raise_erupt_odds + input.raise_erupt_hurt);
    if (input.damage_increase)
        object.setDynamicProperty('rune_hurt:damage_increase', proto.damage_increase + input.damage_increase);
    if (input.double_damage)
        object.setDynamicProperty('rune_hurt:double_damage', proto.double_damage + input.double_damage);
    object.setDynamicProperty('rune_hurt:add_rune', input.add_rune ?? proto.add_rune);
    object.setDynamicProperty('rune_hurt:self_rune', input.self_rune ?? proto.self_rune);
}
;
function MergeProperty(proto, alter) {
    return { ...proto, ...alter };
}
;
function GetProperty(entity) {
    if (!entity || !entity.isValid())
        return RUNE_PROPERTY_DEFAULT;
    const getProperty = (key, initial) => entity?.getDynamicProperty(`rune_hurt:${key}`) ?? initial;
    return {
        raise_basic_attack: getProperty('raise_basic_attack', RUNE_PROPERTY_DEFAULT.raise_basic_attack),
        raise_erupt_odds: getProperty('raise_erupt_odds', RUNE_PROPERTY_DEFAULT.raise_erupt_odds),
        raise_erupt_hurt: getProperty('raise_erupt_hurt', RUNE_PROPERTY_DEFAULT.raise_erupt_hurt),
        damage_increase: getProperty('damage_increase', RUNE_PROPERTY_DEFAULT.damage_increase),
        double_damage: getProperty('double_damage', RUNE_PROPERTY_DEFAULT.double_damage),
        basic_attack: getProperty('basic_attack', RUNE_PROPERTY_DEFAULT.basic_attack),
        erupt_odds: getProperty('erupt_odds', RUNE_PROPERTY_DEFAULT.erupt_odds),
        erupt_hurt: getProperty('erupt_hurt', RUNE_PROPERTY_DEFAULT.erupt_hurt),
        self_rune: getProperty('self_rune', RUNE_PROPERTY_DEFAULT.self_rune),
        add_rune: getProperty('add_rune', RUNE_PROPERTY_DEFAULT.add_rune),
    };
}
;
function CreateEmptyProperty(input) {
    const proto = {};
    for (const key in RUNE_PROPERTY_DEFAULT) {
        if (RUNE_PROPERTY_DEFAULT.hasOwnProperty(key)) {
            proto[key] = RUNE_PROPERTY_DEFAULT[key];
        }
    }
    ;
    return MergeProperty(proto, input);
}
;
var RUNE_PROPERTY_DEFAULT;
(function (RUNE_PROPERTY_DEFAULT) {
    RUNE_PROPERTY_DEFAULT[RUNE_PROPERTY_DEFAULT["raise_basic_attack"] = 0] = "raise_basic_attack";
    RUNE_PROPERTY_DEFAULT[RUNE_PROPERTY_DEFAULT["raise_erupt_odds"] = 0] = "raise_erupt_odds";
    RUNE_PROPERTY_DEFAULT[RUNE_PROPERTY_DEFAULT["raise_erupt_hurt"] = 0] = "raise_erupt_hurt";
    RUNE_PROPERTY_DEFAULT[RUNE_PROPERTY_DEFAULT["damage_increase"] = 0] = "damage_increase";
    RUNE_PROPERTY_DEFAULT[RUNE_PROPERTY_DEFAULT["double_damage"] = 1] = "double_damage";
    RUNE_PROPERTY_DEFAULT[RUNE_PROPERTY_DEFAULT["basic_attack"] = 5] = "basic_attack";
    RUNE_PROPERTY_DEFAULT[RUNE_PROPERTY_DEFAULT["erupt_odds"] = 10] = "erupt_odds";
    RUNE_PROPERTY_DEFAULT[RUNE_PROPERTY_DEFAULT["erupt_hurt"] = 150] = "erupt_hurt";
    RUNE_PROPERTY_DEFAULT["self_rune"] = "rune_void";
    RUNE_PROPERTY_DEFAULT["add_rune"] = "rune_void";
})(RUNE_PROPERTY_DEFAULT || (RUNE_PROPERTY_DEFAULT = {}));
;
